#include<iostream>
using namespace std;


void swap(int *left, int *right)
{
    int temp = *left;
    *left = *right;
    *right = temp;
}


void selectionSort(int arr[] ,int n)
{
    for(int i=0;i<n;i++)
    {
         int max_num= i ;
         for(int j=i+1;j<n;j++)
             if(arr[j] < arr[max_num])
                 max_num = j;
         swap( arr[i],arr[max_num]);
     }
}

void print(int *arr,int n)
{
    for(int i=0;i<n;i++)
        cout<< arr[i]<<' ' ;
    cout<< endl;

 }

int main()
{
    int a[11] ={2, 8, 4, 5, 9, 4, 42, 0, 3, 6, 8};
    int n=11;
    selectionSort(a,n);
    print(a,n);
    return 0;
}


